package com.saikuo.service.controller;

import com.saikuo.service.api.ApiResultModel;
import com.saikuo.service.service.ICouponService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by shanchangyu on 16/11/03.
 */
@Api(value = "优惠券接口", description = "用户优惠券相关等")
@RestController
@RequestMapping("/coupon")
public class CouponController {

    @Autowired
    private ICouponService couponService;

    @ApiOperation(value = "加载用户优惠券,状态 0：正常 1：使用 2：过期")
    @RequestMapping(value = "/getUserCoupon", method = RequestMethod.GET)
    public ApiResultModel getUserCoupon(@RequestParam int userId, @RequestParam int status,@RequestParam int page) {
        return couponService.getUserCoupon(userId, status,page);
    }

    @ApiOperation(value = "根据购药总金额加载用户可用优惠券")
    @RequestMapping(value = "/getUserCouponAccordPrice", method = RequestMethod.GET)
    public ApiResultModel getUserCouponAccordPrice(@RequestParam int userId, @RequestParam Double price,@RequestParam int page) {
        return couponService.getUserCouponAccordPrice(userId, price,page);
    }

}
